<template>

    <el-table
            :data="tableData"
            stripe
            highlight-current-row
            @current-change="handleCurrentChange"
            style="width: 100%;"
            :default-sort = "{prop: 'date', order: 'descending'}"
            @click="wkk"
    >
<!--        <el-table-column-->
<!--                prop="imgid"-->
<!--                label="图片ID"-->
<!--                sortable-->
<!--                width="100">-->
<!--        </el-table-column>-->
        <el-table-column
                prop="date"
                label="日期"
                sortable
                width="150">
        </el-table-column>
        <el-table-column
                prop="time"
                label="时间"
                :formatter="formatter">
        </el-table-column>
        <el-table-column
                prop="tag"
                label="标签"
                width="80">
        </el-table-column>

        <el-table-column
                label="来自相机"
                width="100">
            <template slot-scope="scope">
                <el-button @click="handleClick(scope.row)"  size="small">{{scope.row.cameraid}}</el-button>
            </template>
        </el-table-column>

        <el-table-column
                fixed="right"
                label="操作"
                width="100">
            <template slot-scope="scope">
                <el-button @click="wkk"  size="small">查看图片</el-button>
            </template>
        </el-table-column>
    </el-table>
</template>

<script>
    import API from "../../api";
    export default {
        name: "foreign_list",
        data(){
            return{
                tableData: [
                    {
                        "imgid": "1",
                        "tag": "people",
                        "time": "2017-09-11T00:00:00Z",
                        "date": "2019-09-12",
                        "cameraid": "1",
                        "url": "test1"
                    }]

            }
        },
        methods:{
            getList(){
                API.foreignList().then(res=>{
                    if(res.code){
                        alert(res.message);
                        return;
                    }
                    this.tableData = res
                }).catch(msg => {
                    if(res.code){
                        alert(res.message);
                        return;
                    }
                    alert(msg)
                })
            },
            handleClick(item){
                console.log(item)
                this.$router.push({path: `/camera/`+item.cameraid+`/main`})
            },
            watchimg(item){

            },
            wkk(){
                alert("?>>>")
            },
            handleCurrentChange(val) {
                console.log(val.url)
            },

        },
        mounted() {
            this.getList()
        },
    }


</script>

<style scoped>


</style>